<?php

/**

 * Date: 2015/7/12

 */
session_start();
class IndexAction extends BaseAction
{
    function __construct()
    {
        $this->no_login=['index','verify','login'];
        parent::__construct();
    }
    public function index()
    {
        echo $this->display();
    }
    public function verify(){
        vcode::ImageCode();
    }
    function login(){
        if(Req::post('action')=='login_act'){
            $svali =strcmp(strtolower($_SESSION['verif']),Req::post('yz'));
            if ($svali || !$_SESSION['verif'])
                show_msg('请不要从外部提交数据!','?a=login',2000);

            $user = new mangerlogin();
            $r=$user->login(Req::post('username'), Req::post('password'));
            //var_dump($r);
            if ($r == 1) {
                show_msg('成功登录，正在转向管理管理主页！', 1, 1);
            }else {
                show_msg('登陆失败,请重新登录',"?a=login",3000);
            }
        }
        $_SESSION['verif'] = $yz = sha1(uniqid(rand(), true));
        $this->assign('yz',$yz);
        $this->assign('title',$this->webname.'登录');
        $this->display('login');

    }
    function right(){
        $this->display('right');
    }
    function out(){
        $user=new mangerlogin();
        $user->exitSys();
        show_msg('退出',1,1);
    }
}